package com.xls.dormitoryservice.controller;


import com.xls.commonutils.Result;
import com.xls.dormitoryservice.entity.Building;
import com.xls.dormitoryservice.service.BuildingService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author xls
 * @since 2021-03-23
 */
@RestController
@RequestMapping("/dormitory/building")
@Api(value="区域/楼层接口")
@Slf4j
public class BuildingController {

    @Autowired
    private BuildingService buildingService;

    @GetMapping("/buildingList")
    public Result<List<Building>> buildingList() {
        return Result.success(buildingService.buildingList());
    }

    @GetMapping("/floorList")
    public Result<List<Building>> floorList() {
        return Result.success(buildingService.floorList());
    }

    @GetMapping("/floorListById/{id}")
    public Result<List<Building>> floorListById(@PathVariable("id") String id) {
        return Result.success(buildingService.floorListById(id));
    }

    @GetMapping("/building/{id}")
    public Result<Building> building(@PathVariable("id") String id) {
        return Result.success(buildingService.building(id));
    }

    @GetMapping("/floor/{id}")
    public Result<Building> floor(@PathVariable("id") String id) {
        return Result.success(buildingService.floor(id));
    }

}

